<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>js条件语句与switch语句</title>
</head>
<body>
<script type="text/javascript">
    /**
     * if
     * switch
     *
     */

    var a = 13;

    if (a < 4) {
        console.log('条件成功~~');
    }


    if (a < 6) {

    } else if (a > 8) {
        console.log('a > 8执行了~~')
    }

    if (a < 6) {
        console.log('执行了a < 6')
    } else if (a < 8) {
        console.log('执行了a < 8')
    } else {
        console.log('执行了else')
    }


    var a = 1;  //支持字符串的

    switch (a) {
        case 1:
            console.log('a = 1');
            break;
        case 2:
            console.log('a = 2');
            break;
        default:
            console.log('a = default');
    }



    function test(a) {
        switch (a) {
            case "aaa":
                console.log('1111');
                break;
            case "bbb":
                console.log('2222');
                break;
            default:
                console.log(' default');
        }
    }


</script>


<p>
    <input type="submit" value="界面上显示的内容" name="Su1" onclick="test('aaa')"/>
</p>
</body>
</html>